libxl: Permit multithreaded event waiting
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 27 Jan 2012 17:01:23 +0000 (17:01 +0000)
committerIan Jackson <ian.jackson@eu.citrix.com>
Fri, 27 Jan 2012 17:01:23 +0000 (17:01 +0000)
commit62a394f4eb7c8b4f5e98eaed30c4c522d8249162
tree52729346b063c9a438bd48224873e76e5652c3ae
parent705fdc03cd7d78643c4dece8564d0bba04eb2c0f
libxl: Permit multithreaded event waiting

Previously, the context would be locked whenever we were waiting in
libxl's own call to poll (waiting for operating system events).

This would mean that multiple simultaneous calls to libxl_event_wait
in different threads with different parameters would not work
properly.

If we simply unlock the context, it would be possible for another
thread to discover the occurrence of the event we were waiting for,
without us even waking up, and we would remain in poll.  So we need a
way to wake up other threads: a pipe, one for each thread in poll.

We also need to move some variables from globals in the ctx to be
per-polling-thread.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl_event.c
tools/libxl/libxl_internal.h